package com.example.demo.controller;

import com.example.demo.model.Lqmana;
import com.example.demo.service.ILqmanaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Api(tags = "物品领取信息")
@RestController
@RequestMapping("/swagger13")
public class LqmanaController {
    @Autowired
    private ILqmanaService lqmanaService;
    @CrossOrigin
    @ApiOperation(value="添加发放物品信息")
    @PostMapping("/insertLqmana")
    public int insertLqmana(@RequestBody Lqmana lqmana){
        System.out.println("进入添加发放物品信息信息接口" );
        return lqmanaService.insertLqmana(lqmana);
    }

    @PostMapping("/getAllLqmana")
    public List<Lqmana> getAllLqmana(@RequestBody Lqmana lqmana)
    {
        System.out.println("进入查询方法");
        List<Lqmana> listLqmana=lqmanaService.getAllLqmana(lqmana);
        return listLqmana;
    }
    @PostMapping("/editLqmana")
    public int EditLqmana(@RequestBody Lqmana lqmana){
        System.out.println("添加修改方法");
        return lqmanaService.updateLqmana(lqmana);
    }
    @GetMapping("/delLqmana")
    public int Delete(int lbid){
        System.out.println("进入删除方法");
        int returnValues=0;
        if(lbid!=0){
            Lqmana lqmana=new Lqmana();
            lqmana.setLbid(lbid);
            returnValues=lqmanaService.deleteLqmana(lqmana);
        }
        return returnValues;
    }

    @GetMapping("/getOneLqmana")
    public Lqmana getLqmana(int lbid){
        Lqmana lqmana=new Lqmana();
        System.out.println("进入单条查询方法");
        if(lbid!=0){
            Lqmana lqmana1=new Lqmana();
            lqmana1.setLbid(lbid);
            lqmana=lqmanaService.getLqmana(lqmana1);
            System.out.println("返回的数据集合为:"+lqmana.getLbid());
        }
        return lqmana;
    }
}
